<template>
  <div class="edu-list">
    <div class="middle">
      <ul>
        <li v-for="item in eduList">
          <h3>{{item.college}} <strong @click="toEdit(item.id)">✎</strong></h3>
          <p>{{item.highestDegree}}/{{item.professionalClassification}}</p>
          <span>{{item.admissionTime|dateFormat}}至{{item.graduationTime|dateFormat}}</span>
        </li>

        <li>
          <h3>成都理工大学 <strong @click="toEdit">✎</strong></h3>
          <p>本科/工商管理系</p>
          <span>2014-09至2018年07</span>
        </li>
      </ul>
      <div class="add-work" @click="toAdd">✚ 添加教育经历</div>
    </div>
  </div>
</template>

<script>
  import {dateFormat} from '../model/Date';

  export default {
    name: "EduList",
    data() {
      return {
        eduList: []
      }
    },
    created() {
      this.$http.get(this.$config.edu_exp_uri + "?userId=" + this.$storage.get("user").id).then(resp => {
        console.log(resp.body);
        this.eduList = resp.body
      });
    },
    methods: {
      toAdd() {
        this.$router.push({path: '/add-edu'});
      },
      toEdit(id) {
        this.$router.push({path: '/edit-edu/' + id});
      }
    },
    filters: {
      dateFormat(time) {
        return dateFormat(new Date(time), 'yyyy年MM月');
      }
    }
  }
</script>

<style scoped>
  * {
    margin: 0;
    padding: 0;
  }

  li {
    list-style-type: none;
  }

  body {
    font-family: 微软雅黑;
    font-size: 14px;
  }

  a {
    text-decoration: none;
    color: #595959;
  }

  a:hover {
    text-decoration: underline;
  }

  .middle {
    width: 100%;
    overflow: hidden;
  }

  .middle ul {
    overflow: hidden;
    margin: 0 auto;
  }

  .middle ul li {
    width: 100%;
    padding: 10px 0;
    border-bottom: dotted 1px #E4E4E4;
  }

  .middle ul li h3 {
    font-weight: 400;
    font-size: 15px;
  }

  .middle ul li h3 strong {
    float: right;
    display: inline;
    color: #595959;
  }

  .middle ul li p {
    font-size: 13px;
    margin: 10px 0;
    color: #595959;
  }

  .middle ul li span {
    font-size: 13px;
    color: #595959;
  }

  .add-work {
    width: 90%;
    margin: 30px auto 0 auto;
    height: 50px;
    line-height: 50px;
    border: solid 1px #E4E4E4;
    border-radius: 4px;
    text-align: center;
    color: #595959;
  }

</style>
